<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<head>

</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 系统管理 <span class="c-gray en">&gt;</span> 用户管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>

<article class="page-container">
	<div class="cl pd-5 bg-1 bk-gray">
		<!-- 搜索栏 -->
		<div class="row">
			<label class="form-label col-xs-1">账号:</label>
			<div class="formControls col-xs-2">
				<input type="text" class="input-text" id="account"/>
			</div>
			<label class="form-label col-xs-1">昵称:</label>
			<div class="formControls col-xs-2">
				<input type="text" class="input-text" id="nickName"/>
			</div>
			<label class="form-label col-xs-1">用户类型:</label>
			<div class="formControls col-xs-2">
				<span class="select-box">
					<select class="select" id="userType" name="userType" size="1">
						<option value="">-- 请选择用户类型 --</option>
						<option value="0" <c:if test="${entity.userType == '0'}">selected</c:if>>普通用户</option>
						<option value="1" <c:if test="${entity.userType == '1'}">selected</c:if>>教师</option>
						<option value="2" <c:if test="${entity.userType == '2'}">selected</c:if>>管理员</option>
					</select>
				</span>
			</div>
			<div class="formControls col-xs-3">
				<a href="javascript:query();" class="btn btn-success radius"><i class="Hui-iconfont">&#xe665;</i> 查询</a>
				<a href="javascript:void(0);" onclick="reset(this)" class="btn btn-secondary radius"><i class="Hui-iconfont">&#xe665;</i> 重置</a>
			</div>
		</div>

	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-5"> 
		<span class="l">
			<a href="javascript:;" onclick="layer_show('添加用户','${ctx}/user/findOne','770','450')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加用户</a>
		</span>
	</div>
	<div class="mt-20">
		<table class="table table-border table-bordered table-bg table-sort">
			<thead>
				<tr class="text-c">
					<th width="25">序号</th>
					<th width="100">登录账号</th>
					<th width="100">用户昵称</th>
					<th width="100">用户类型</th>
					<th width="60">状态</th>
					<th width="130">创建时间</th>
					<th width="100">操作</th>
				</tr>
			</thead>
		</table>
	</div>
</article>
<script type="text/javascript">
var datatable = null;
$(function(){
	datatable = $('.table-sort').DataTable({
		pagingType: "input",
		"sScrollX": "100%",  
		"sScrollXInner": "100%",  
		"bScrollCollapse": true,
		ordering:false,
		ajax: {
			url: "${ctx}/user/queryByPage",
			type: 'post',
			data: function(d) {
				d.search_LIKE_account=$('#account').val();
                d.search_LIKE_nickName=$('#nickName').val();
                d.search_EQ_userType=$('#userType').val();

            }
		},
		fnDrawCallback:function(oSettings){//表格画完的回调函数
			var obj = oSettings.json.otherData;
        },
		columns: [{
			"data": null,
			"class": "text-c",
			"render":function(data, type, row, meta){
				return  meta.row + 1;
			}
		},{
			"data": "account",
			"defaultContent": "",
			"class": "text-c"
		},{
			"data": "nickName",
			"defaultContent": "",
			"class": "text-c"
		}, {
            "data": "userType",
            "defaultContent": "",
            "class": "text-c",
			"render" : function (data, type, row, meta) {
                if(data=="0"){
                    return "普通用户";
				}else if(data=="1"){
                    return '教师';
				}else if(data=="2"){
                    return '管理员';
                }else{
				    return "未知";
				}
            }
        },{
            "data": "available",
            "defaultContent": "",
            "class": "text-c",
			"render" : function (data, type, row, meta) {
				if(data=='false'){
				   return '正常';
				}else if(data=='true'){
				   	return '锁定';
				}else {
				    return "未知";
				}
            }
        },{
            "data": "createDate",
            "defaultContent": "",
            "class": "text-c"
        },{
            "data": null,
            "class": "text-c",
            render: function(data, type, row, meta) {
                var btns = new Array();
               	if(row.available=='true'){
                   btns[btns.length] = butInfo("&#xe6dc;","解锁","changeState('${ctx}/user/updateAvailableById.do?available=false','"+row.id+"',1,'解锁')");
                }else{
                   btns[btns.length] = butInfo("&#xe6de;","锁定","changeState('${ctx}/user/updateAvailableById.do?available=true','"+row.id+"',0,'锁定')");
                }
                btns[btns.length] = butInfo("&#xe63f;","修改密码","layer_show('修改密码','${ctx}/pageSkip/jumpPage.do?pageUrl=system/user/updatePwd&id="+row.id+"&account="+row.account+"','400','270')");
                btns[btns.length] = butInfo("&#xe6df;","编辑用户","layer_show('编辑用户','${ctx}/user/findOne.do?id="+row.id+"','770','450')");
            	if(row.userType != '2'){
                     btns[btns.length] = butInfo("&#xe6e2;","删除","delEntity('${ctx}/user/deleteEntity.do','"+row.id+"',true)");
                }
                return getDTOperateBtn(btns);
            }
        }],
		initComplete:function(data){
		}
	});
})

</script>
</body>
